<?php

/**
 * MarqueRestriction form.
 *
 * @package    emc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class MarqueRestrictionForm extends BaseMarqueRestrictionForm
{
  public function configure()
  {
  	$this->setWidgets(array(
			'jobboard_id'				=>		new sfWidgetFormSelect(array('choices' => $this->getJobboardList())),
			'name'						=>		new sfWidgetFormInput(),
		));
				
		$this->widgetSchema->setNameFormat('marque_restriction[%s]');
		$this->widgetSchema->setLabels(array(
			'jobboard_id'				=>		'Website',
			'name'						=>		'Tên',
		));
  }

  private function getJobboardList()
  {
  	$q = Doctrine_Query::create()
  		->select('j.id, j.name')
  		->from('Jobboard j');
  	$results = $q->fetchArray();
  	$jobboard = array();
  	foreach ($results as $result)
  		$jobboard[$result['id']] = $result['name'];
  	return $jobboard;
  }
}
